<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUserInteractMsgLogTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_interact_msg_log', function (Blueprint $table) {
            $table->smallIncrements('id');
            $table->integer('user_id')->default(0)->comment('互动方用户ID');
            $table->integer('msg_user_id')->default(0)->comment('被互动方用户ID');
            $table->tinyInteger('msg_type')->default(1)->comment('消息分类：1-动态点赞，2-动态评论');
            $table->integer('msg_object_id')->default(0)->comment('消息主体ID，如动态相关则为动态ID');
            $table->string('detail', 150)->default(1)->comment('消息详情');
            $table->timestamps();
            $table->tinyInteger('read')->default(0)->comment('已读状态');
            $table->tinyInteger('flag')->default(1)->comment('记录状态');
            $table->index('msg_user_id', 'msg_user_id');
            $table->index('user_id', 'user_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_interact_msg_log');
    }
}
